#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define CREATE( target, type )		( target ) = ( type * ) malloc( sizeof (type) )

typedef unsigned char bool;
#define FALSE 	0
#define TRUE 	1

typedef enum {
    MODE_MANUAL, MODE_AUTO
} operating_modes;

typedef enum {
    PLANE_FLYING, PLANE_WAITING_TO_LAND, 	PLANE_LANDING, \
    PLANE_DOCKED, PLANE_WAITING_FOR_LAUNCH, 	PLANE_LAUNCHING
} plane_states;

typedef enum {
    STRIP_FREE, STRIP_USED, STRIP_BLOCKED
} strip_states;

typedef struct plane_data PLANE_DATA;
typedef struct strip_data STRIP_DATA;


struct plane_data
{
    PLANE_DATA *	next;
    PLANE_DATA *	prev;
    
    int			ID;
    int			fuel;
    int 		distance;
    int			state;
    char		emergency;
    int			priority;
    bool		retoute;
};

struct strip_data
{
    STRIP_DATA *	next;
    
    int			ID;
    int			state;
	 
};

int no_strips = 10;
int hangar_vol = 50;
int no_planes[3];
int mode;

PLANE_DATA * first_plane;
PLANE_DATA * last_plane;
STRIP_DATA * first_strip;
STRIP_DATA * last_strip;

/* function prototypes */
void	assign_pri	( void );
int 	main 		( void );
int	main_loop	( void );
void	reroute_planes	( void );
void	sort		( PLANE_DATA * );

